<?php

namespace Acme\DomotiqueBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;

use Acme\DomotiqueBundle\Entity\Element;


/**
 */
class ElementController extends Controller
{

    public function getAllAction(){

    	$elements = $this->getDoctrine()
        	->getRepository('DomotiqueBundle:Element')
        	->findAll();
        $tabelements = array();
        foreach($elements as $element){
        	$tabelements[$element->getRoom()][] = $element->__toArray();
        }
       	return new Response(json_encode(array("response_code" => "ok", "elements" => $tabelements)));
    }
    
}